#!/bin/sh
set -euo pipefail

package_name="dynamix.system.autofan"

echo "Version defined as [$1]"
echo "Source code directory defined as [$2]"

if command -v makepkg > /dev/null; then

    file_name=$(printf "%s/%s-%s-x86_64-1.txz" "$(pwd)" "$package_name" "$1")

    cd "$2"
	
    echo "创建 $file_name"
    makepkg --linkadd y --chown y "$file_name"

    echo "$file_name MD5: $(md5sum $file_name | awk '{print $1}')"
else
    echo "你的系统中没有makepkg"
fi

exit 0